//
//  MonsterView.h
//  FruitCrush
//
//  Created by gaoyu on 15/7/9.
//
//

#ifndef __FruitCrush__MonsterView__
#define __FruitCrush__MonsterView__

#include "cocos2d.h"
#include "Monster.h"
#include "AttackAction.h"
#include "MonsterBeAttackRecorder.h"

USING_NS_CC;

typedef std::function<void(Ref*)> monsterViewCallback;
typedef std::function<void(Ref*)> monsterViewBossAttackCallback;

class MonsterView : public cocos2d::Layer
{
public:
	CC_SYNTHESIZE(bool, m_isPause, IsPause);
    static MonsterView *create(int type);
    bool init(int type);
    MonsterView();
    ~MonsterView();
    virtual void update(float dt) override;
    static Size getSize();
    void beAttacked(MonsterBeAttackRecorder *recorder);
    void setCallback(const monsterViewCallback& callback);
    void setBossAttackCallback(const monsterViewBossAttackCallback& callback);
    void beHealthed(int num);
    void destoryMonsterProtectCover();
protected:
    monsterViewCallback _callback;
    monsterViewBossAttackCallback _bossAttackCallback;
private:
    Monster *monster;
    __Array *attackArray;
    CC_SYNTHESIZE(float, lastTime, LastTime);
    void bgInit(int type);
    void monsterInit(int type);
    void showAction(int type);
    void checkMonsterBeAttack();
    void monsterViewBossAttackCallbackFun(Ref *sender);
    void setPause(bool isPause);

    
    
    
};

#endif /* defined(__FruitCrush__MonsterView__) */
